/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package artistic;

import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;

/**
 *
 * @author rurik
 */
public class FilterBlur {
    private static PaintImage soucreImage;

    static void blur(PaintWindow paintWindow1) {
        soucreImage = paintWindow1.getImage();
        TiledCanvas canvas = soucreImage.getLayer(0);
        int height = canvas.getHeight();
        int width = canvas.getWidth();
        BufferedImage bSrc = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        BufferedImage bDes = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
      
        for(int y = 0; y<height; ++y)
        {
            for(int x = 0; x<width; ++x)
            {
                int color = canvas.getPixel(x,y);
                bSrc.setRGB(x, y, color);
            }
        }
        
	float[] matrix = new float[100];
	for (int i = 0; i < 100; i++)
		matrix[i] = 1.0f/100.0f;

        ConvolveOp convolve = new ConvolveOp( new Kernel(10, 10, matrix), ConvolveOp.EDGE_NO_OP, null);
        convolve.filter(bSrc, bDes);
        
        for(int y = 0; y<height; ++y)
        {
            for(int x = 0; x<width; ++x)
            {
                int color = bDes.getRGB(x,y);
                canvas.setPixel(x, y, color);
            }
        }
        paintWindow1.repaint();
    }

}
